package com.my.adminservice.user.controller;

import com.my.adminservice.user.domain.dto.PasswordLoginDTO;
import com.my.adminservice.user.service.ISysUserService;
import com.my.mycommondomain.domian.R;
import com.my.mycommondomain.domian.vo.TokenVO;
import com.my.mycommonsecurity.domain.dto.TokenDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/sys_user")
public class SysUserController {
    @Autowired
    private ISysUserService sysUserService;
    /**
     * 手机号、密码登录
     */
    @PostMapping("/login/password")
    public R<TokenVO> login(@Validated @RequestBody PasswordLoginDTO loginDTO) {
        // 用户登录，获取登录token
        TokenDTO tokenDTO = sysUserService.login(loginDTO);
        return R.ok(tokenDTO.convertToVo());
    }
}
